#!/usr/bin/python

# Launch a range query

from pyodm.document import Document
from pyodm.fields import *
from pyodm.criteria import Criteria
import sys

class TestDocument(Document):
    field1 = StringField()
    field2 = IntegerField()

obj = TestDocument(field1="field12", field2=17)
obj.save()
obj = TestDocument(field1="field13", field2=18)
obj.save()
obj = TestDocument(field1="field14", field2=19)
obj.save()

crit1 = Criteria("field1", "<", "field14")
crit2 = Criteria("field1", ">", "field1")
objs = TestDocument.get([crit1, crit2])
for obj in objs:
    print "Key: %s\nfield1: %s\nfield2: %s\n===============\n" % (obj.getKey(), obj.field1, obj.field2)

